package cn.zcscloud.mall.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;

import java.util.List;

@Data
public class PageRequest<T> {
    private Long pageSize;//每页的条数
    private Long pageNum;//当前的页码
    private Long total;//总条数
    private Long totalPage;//总页数
    private List<T> list;//数据集合

    public static PageRequest init(IPage page){
        PageRequest<Object> pageRequest = new PageRequest<>();

        pageRequest.setPageSize(page.getSize());
       // pageRequest.setPageNum(page.getPages());
        pageRequest.setPageNum(page.getCurrent());
        pageRequest.setList(page.getRecords());
        pageRequest.setTotalPage(page.getPages());
        pageRequest.setTotal(page.getTotal());
        return pageRequest;
    }
}
